﻿<UserControl x:Class="ModernUILogViewer.Content.ContentSearchLevel"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"             
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"                
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"                
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             xmlns:model="clr-namespace:ModernUILogViewer.Model"
             xmlns:business="clr-namespace:ModernUILogViewer.Business"
             xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">

    <UserControl.Resources>
        <!-- not used -->
        <ObjectDataProvider x:Key="levels" 
                        MethodName="GetNames" ObjectType="{x:Type sys:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="model:LOG_LEVEL" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>

    </UserControl.Resources>

    <Grid>
        <StackPanel>
            <ListBox ItemsSource="{Binding ListLevel}" Margin="5, 10, 0, 0">
                <ListBox.Resources>
                    <!-- DataContextSpy is used to bind to the FilterLogEntries, because DataContext would be point to ListLevel instead -->
                    <business:DataContextSpy x:Key="spy" />
                </ListBox.Resources>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <CheckBox IsChecked="{Binding IsSelected}" >
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Checked" >
                                        <i:InvokeCommandAction Command="{Binding Source={StaticResource spy}, Path=DataContext.FilterLogEntries}" />
                                    </i:EventTrigger>
                                    <i:EventTrigger EventName="Unchecked">
                                        <i:InvokeCommandAction Command="{Binding Source={StaticResource spy}, Path=DataContext.FilterLogEntries}" />
                                    </i:EventTrigger>
                                    <i:EventTrigger EventName="MouseRightButtonDown" >
                                        <i:InvokeCommandAction Command="{Binding Source={StaticResource spy}, Path=DataContext.ExlusiveSelectLevel}" CommandParameter="{Binding}" />                                                                                    
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </CheckBox>
                            <TextBlock Text="{Binding Level}" />
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            <TextBlock FontSize="{StaticResource SmallFontSize}" Margin="0, 15, 0, 0">
            * Right click to select only one level
            </TextBlock>
        </StackPanel>
    </Grid>


</UserControl>
